package com.gpframework.module.manufacture.domain.req;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gpframework.common.utils.StringUtils;
import com.gpframework.module.base.domain.req.BaseReq;
import com.gpframework.module.manufacture.domain.GpWeightReductionRuleSetting;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * @ClassName GpWeightReductionRuleSettingReq
 * @Author gpframework
 * @Date 2023-12-14
 * @Version 1.0.0
 * @Description 列表查询信息体
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
public class GpWeightReductionRuleSettingReq extends BaseReq {
    private static final long serialVersionUID = 1L;

         @ApiModelProperty("品牌id")
     private String brandId;
     @ApiModelProperty("品牌名称")
     private String brandName;
     @ApiModelProperty("产品名")
     private String productName;
     @ApiModelProperty("红色差异值")
     private Long redRate;
     @ApiModelProperty("黄色最小差异值")
     private Long yellowMinRate;
     @ApiModelProperty("黄色最大差异值")
     private Long yellowMaxRate;
     @ApiModelProperty("排序")
     private Integer sort;

    /**
    * @Description 生成查询wrapper
    * @Author greatplan@qq.com
    * @Date 2020-11-04 16:04
    * @Param [lqw]
    * @Param [isVO] 是否vo查询体，true的话走的是mapper.xml里面的查询语句，不过查询语法还是mybatis-plus，主要用于某些关联查询出一些非数据表字段
    * @Return void
    */
    public void generatorQuery(QueryWrapper<GpWeightReductionRuleSetting> lqw,boolean isVo) {
        String alias = "";
        if (isVo) {
            alias = "gp.";
            lqw.eq(alias+"del_status",0);
        }
        if (StringUtils.isNotBlank(this.getBrandId())){
        lqw.eq(alias+"brand_id" ,this.getBrandId());
        }
        if (StringUtils.isNotBlank(this.getBrandName())){
            lqw.like(alias+"brand_name",this.getBrandName());
        }
        if (StringUtils.isNotBlank(this.getProductName())){
            lqw.like(alias+"product_name",this.getProductName());
        }
        if (this.getRedRate() != null){
        lqw.eq(alias+"red_rate" ,this.getRedRate());
        }
        if (this.getYellowMinRate() != null){
        lqw.eq(alias+"yellow_min_rate" ,this.getYellowMinRate());
        }
        if (this.getYellowMaxRate() != null){
        lqw.eq(alias+"yellow_max_rate" ,this.getYellowMaxRate());
        }
        if (this.getSort() != null){
        lqw.eq(alias+"sort" ,this.getSort());
        }
    }
}
